home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / samples / docbook / xsl / html / chunk.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-09  |  23.3 KB  |  585 lines  |  [□□□□/□□□□]

  1.     chunk.xslZ˛π¢tÚπ¢tÚÅŎ3<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2.                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  3.         version="1.0"
  4.                 exclude-result-prefixes="doc">
  5.  
  6. <xsl:import href="docbook.xsl"/>
  7. <xsl:import href="chunk-common.xsl"/>
  8.  
  9. <!-- ==================================================================== -->
  10.  
  11. <xsl:template name="process-chunk-element">
  12.   <xsl:choose>
  13.     <xsl:when test="$chunk.first.sections = 0">
  14.       <xsl:call-template name="chunk-first-section-with-parent"/>
  15.     </xsl:when>
  16.     <xsl:otherwise>
  17.       <xsl:call-template name="chunk-all-sections"/>
  18.     </xsl:otherwise>
  19.   </xsl:choose>
  20. </xsl:template>
  21.  
  22. <xsl:template name="process-chunk">
  23.   <xsl:param name="prev" select="."/>
  24.   <xsl:param name="next" select="."/>
  25.  
  26.   <xsl:variable name="ischunk">
  27.     <xsl:call-template name="chunk"/>
  28.   </xsl:variable>
  29.  
  30.   <xsl:variable name="chunkfn">
  31.     <xsl:if test="$ischunk='1'">
  32.       <xsl:apply-templates mode="chunk-filename" select="."/>
  33.     </xsl:if>
  34.   </xsl:variable>
  35.  
  36.   <xsl:if test="$ischunk='0'">
  37.     <xsl:message>
  38.       <xsl:text>Error </xsl:text>
  39.       <xsl:value-of select="name(.)"/>
  40.       <xsl:text> is not a chunk!</xsl:text>
  41.     </xsl:message>
  42.   </xsl:if>
  43.  
  44.   <xsl:variable name="filename">
  45.     <xsl:call-template name="make-relative-filename">
  46.       <xsl:with-param name="base.dir" select="$base.dir"/>
  47.       <xsl:with-param name="base.name" select="$chunkfn"/>
  48.     </xsl:call-template>
  49.   </xsl:variable>
  50.  
  51.   <xsl:call-template name="write.chunk">
  52.     <xsl:with-param name="filename" select="$filename"/>
  53.     <xsl:with-param name="content">
  54.       <xsl:call-template name="chunk-element-content">
  55.         <xsl:with-param name="prev" select="$prev"/>
  56.         <xsl:with-param name="next" select="$next"/>
  57.       </xsl:call-template>
  58.     </xsl:with-param>
  59.   </xsl:call-template>
  60. </xsl:template>
  61.  
  62. <xsl:template name="chunk-first-section-with-parent">
  63.   <!-- These xpath expressions are really hairy. The trick is to pick sections -->
  64.   <!-- that are not first children and are not the children of first children -->
  65.  
  66.   <xsl:variable name="prev"
  67.     select="(preceding::book[1]
  68.              |preceding::preface[1]
  69.              |preceding::chapter[1]
  70.              |preceding::appendix[1]
  71.              |preceding::part[1]
  72.              |preceding::reference[1]
  73.              |preceding::refentry[1]
  74.              |preceding::colophon[1]
  75.  
  76.              |preceding::sect1[$chunk.section.depth > 0
  77.                                and preceding-sibling::sect1][1]
  78.  
  79.              |preceding::sect2[$chunk.section.depth > 1
  80.                                and preceding-sibling::sect2
  81.                                and parent::sect1[preceding-sibling::sect1]][1]
  82.  
  83.              |preceding::sect3[$chunk.section.depth > 2
  84.                                and preceding-sibling::sect3
  85.                                and parent::sect2[preceding-sibling::sect2]
  86.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  87.  
  88.              |preceding::sect4[$chunk.section.depth > 3
  89.                                and preceding-sibling::sect4
  90.                                and parent::sect3[preceding-sibling::sect2]
  91.                                and ancestor::sect2[preceding-sibling::sect2]
  92.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  93.  
  94.              |preceding::sect5[$chunk.section.depth > 4
  95.                                and preceding-sibling::sect5
  96.                                and parent::sect4[preceding-sibling::sect4]
  97.                                and ancestor::sect3[preceding-sibling::sect3]
  98.                                and ancestor::sect2[preceding-sibling::sect2]
  99.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  100.  
  101.              |preceding::section[$chunk.section.depth > count(ancestor::section)
  102.                                  and preceding-sibling::section
  103.                                  and not(ancestor::section[not(preceding-sibling::section)])][1]
  104.  
  105.              |preceding::article[1]
  106.              |preceding::bibliography[1]
  107.              |preceding::glossary[1]
  108.              |preceding::index[1]
  109.              |preceding::setindex[1]
  110.              |ancestor::set
  111.              |ancestor::book[1]
  112.              |ancestor::preface[1]
  113.              |ancestor::chapter[1]
  114.              |ancestor::appendix[1]
  115.  
  116.              |ancestor::sect1[$chunk.section.depth > 0
  117.                                and preceding-sibling::sect1][1]
  118.  
  119.              |ancestor::sect2[$chunk.section.depth > 1
  120.                                and preceding-sibling::sect2
  121.                                and parent::sect1[preceding-sibling::sect1]][1]
  122.  
  123.              |ancestor::sect3[$chunk.section.depth > 2
  124.                                and preceding-sibling::sect3
  125.                                and parent::sect2[preceding-sibling::sect2]
  126.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  127.  
  128.              |ancestor::sect4[$chunk.section.depth > 3
  129.                                and preceding-sibling::sect4
  130.                                and parent::sect3[preceding-sibling::sect2]
  131.                                and ancestor::sect2[preceding-sibling::sect2]
  132.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  133.  
  134.              |ancestor::sect5[$chunk.section.depth > 4
  135.                                and preceding-sibling::sect5
  136.                                and parent::sect4[preceding-sibling::sect4]
  137.                                and ancestor::sect3[preceding-sibling::sect3]
  138.                                and ancestor::sect2[preceding-sibling::sect2]
  139.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  140.  
  141.              |ancestor::section[$chunk.section.depth > count(ancestor::section)
  142.                                 and not(ancestor::section[not(preceding-sibling::section)])][1]
  143.  
  144.              |ancestor::part[1]
  145.              |ancestor::reference[1]
  146.              |ancestor::article[1])[last()]"/>
  147.  
  148.   <xsl:variable name="next"
  149.     select="(following::book[1]
  150.              |following::preface[1]
  151.              |following::chapter[1]
  152.              |following::appendix[1]
  153.              |following::part[1]
  154.              |following::reference[1]
  155.              |following::refentry[1]
  156.              |following::colophon[1]
  157.  
  158.              |following::sect1[$chunk.section.depth > 0
  159.                                and preceding-sibling::sect1][1]
  160.  
  161.              |following::sect2[$chunk.section.depth > 1
  162.                                and preceding-sibling::sect2
  163.                                and parent::sect1[preceding-sibling::sect1]][1]
  164.  
  165.              |following::sect3[$chunk.section.depth > 2
  166.                                and preceding-sibling::sect3
  167.                                and parent::sect2[preceding-sibling::sect2]
  168.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  169.  
  170.              |following::sect4[$chunk.section.depth > 3
  171.                                and preceding-sibling::sect4
  172.                                and parent::sect3[preceding-sibling::sect2]
  173.                                and ancestor::sect2[preceding-sibling::sect2]
  174.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  175.  
  176.              |following::sect5[$chunk.section.depth > 4
  177.                                and preceding-sibling::sect5
  178.                                and parent::sect4[preceding-sibling::sect4]
  179.                                and ancestor::sect3[preceding-sibling::sect3]
  180.                                and ancestor::sect2[preceding-sibling::sect2]
  181.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  182.  
  183.              |following::section[$chunk.section.depth > count(ancestor::section)
  184.                                  and preceding-sibling::section
  185.                                  and not(ancestor::section[not(preceding-sibling::section)])][1]
  186.  
  187.              |following::bibliography[1]
  188.              |following::glossary[1]
  189.              |following::index[1]
  190.              |following::article[1]
  191.              |following::setindex[1]
  192.              |descendant::book[1]
  193.              |descendant::preface[1]
  194.              |descendant::chapter[1]
  195.              |descendant::appendix[1]
  196.              |descendant::article[1]
  197.              |descendant::bibliography[1]
  198.              |descendant::glossary[1]
  199.              |descendant::index[1]
  200.              |descendant::colophon[1]
  201.              |descendant::setindex[1]
  202.              |descendant::part[1]
  203.              |descendant::reference[1]
  204.              |descendant::refentry[1]
  205.  
  206.              |descendant::sect1[$chunk.section.depth > 0
  207.                                and preceding-sibling::sect1][1]
  208.  
  209.              |descendant::sect2[$chunk.section.depth > 1
  210.                                and preceding-sibling::sect2
  211.                                and parent::sect1[preceding-sibling::sect1]][1]
  212.  
  213.              |descendant::sect3[$chunk.section.depth > 2
  214.                                and preceding-sibling::sect3
  215.                                and parent::sect2[preceding-sibling::sect2]
  216.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  217.  
  218.              |descendant::sect4[$chunk.section.depth > 3
  219.                                and preceding-sibling::sect4
  220.                                and parent::sect3[preceding-sibling::sect2]
  221.                                and ancestor::sect2[preceding-sibling::sect2]
  222.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  223.  
  224.              |descendant::sect5[$chunk.section.depth > 4
  225.                                and preceding-sibling::sect5
  226.                                and parent::sect4[preceding-sibling::sect4]
  227.                                and ancestor::sect3[preceding-sibling::sect3]
  228.                                and ancestor::sect2[preceding-sibling::sect2]
  229.                                and ancestor::sect1[preceding-sibling::sect1]][1]
  230.  
  231.              |descendant::section[$chunk.section.depth > count(ancestor::section)
  232.                                  and preceding-sibling::section
  233.                                  and not(ancestor::section[not(preceding-sibling::section)])])[1]
  234. "/>
  235.  
  236.   <xsl:call-template name="process-chunk">
  237.     <xsl:with-param name="prev" select="$prev"/>
  238.     <xsl:with-param name="next" select="$next"/>
  239.   </xsl:call-template>
  240. </xsl:template>
  241.  
  242. <xsl:template name="chunk-all-sections">
  243.   <xsl:variable name="prev"
  244.     select="(preceding::book[1]
  245.              |preceding::preface[1]
  246.              |preceding::chapter[1]
  247.              |preceding::appendix[1]
  248.              |preceding::part[1]
  249.              |preceding::reference[1]
  250.              |preceding::refentry[1]
  251.              |preceding::colophon[1]
  252.  
  253.              |preceding::sect1[$chunk.section.depth > 0][1]
  254.              |preceding::sect2[$chunk.section.depth > 1][1]
  255.              |preceding::sect3[$chunk.section.depth > 2][1]
  256.              |preceding::sect4[$chunk.section.depth > 3][1]
  257.              |preceding::sect5[$chunk.section.depth > 4][1]
  258.              |preceding::section[$chunk.section.depth > count(ancestor::section)][1]
  259.  
  260.              |preceding::article[1]
  261.              |preceding::bibliography[1]
  262.              |preceding::glossary[1]
  263.              |preceding::index[1]
  264.              |preceding::setindex[1]
  265.              |ancestor::set
  266.              |ancestor::book[1]
  267.              |ancestor::preface[1]
  268.              |ancestor::chapter[1]
  269.              |ancestor::appendix[1]
  270.              |ancestor::part[1]
  271.              |ancestor::reference[1]
  272.              |ancestor::article[1]
  273.              |ancestor::sect1[$chunk.section.depth > 0][1]
  274.              |ancestor::sect2[$chunk.section.depth > 1][1]
  275.              |ancestor::sect3[$chunk.section.depth > 2][1]
  276.              |ancestor::sect4[$chunk.section.depth > 3][1]
  277.              |ancestor::sect5[$chunk.section.depth > 4][1]
  278.              |ancestor::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
  279.  
  280.   <xsl:variable name="next"
  281.     select="(following::book[1]
  282.              |following::preface[1]
  283.              |following::chapter[1]
  284.              |following::appendix[1]
  285.              |following::part[1]
  286.              |following::reference[1]
  287.              |following::refentry[1]
  288.              |following::colophon[1]
  289.  
  290.              |following::sect1[$chunk.section.depth > 0][1]
  291.              |following::sect2[$chunk.section.depth > 1][1]
  292.              |following::sect3[$chunk.section.depth > 2][1]
  293.              |following::sect4[$chunk.section.depth > 3][1]
  294.              |following::sect5[$chunk.section.depth > 4][1]
  295.              |following::section[$chunk.section.depth > count(ancestor::section)][1]
  296.  
  297.              |following::bibliography[1]
  298.              |following::glossary[1]
  299.              |following::index[1]
  300.              |following::article[1]
  301.              |following::setindex[1]
  302.              |descendant::book[1]
  303.              |descendant::preface[1]
  304.              |descendant::chapter[1]
  305.              |descendant::appendix[1]
  306.              |descendant::article[1]
  307.              |descendant::bibliography[1]
  308.              |descendant::glossary[1]
  309.              |descendant::index[1]
  310.              |descendant::colophon[1]
  311.              |descendant::setindex[1]
  312.              |descendant::part[1]
  313.              |descendant::reference[1]
  314.              |descendant::refentry[1]
  315.  
  316.              |descendant::sect1[$chunk.section.depth > 0][1]
  317.              |descendant::sect2[$chunk.section.depth > 1][1]
  318.              |descendant::sect3[$chunk.section.depth > 2][1]
  319.              |descendant::sect4[$chunk.section.depth > 3][1]
  320.              |descendant::sect5[$chunk.section.depth > 4][1]
  321.              |descendant::section[$chunk.section.depth 
  322.                                   > count(ancestor::section)][1])[1]"/>
  323.  
  324.   <xsl:call-template name="process-chunk">
  325.     <xsl:with-param name="prev" select="$prev"/>
  326.     <xsl:with-param name="next" select="$next"/>
  327.   </xsl:call-template>
  328. </xsl:template>
  329.  
  330. <!-- ==================================================================== -->
  331.  
  332. <xsl:template match="/">
  333.   <xsl:choose>
  334.     <xsl:when test="$rootid != ''">
  335.       <xsl:choose>
  336.         <xsl:when test="count(key('id',$rootid)) = 0">
  337.           <xsl:message terminate="yes">
  338.             <xsl:text>ID '</xsl:text>
  339.             <xsl:value-of select="$rootid"/>
  340.             <xsl:text>' not found in document.</xsl:text>
  341.           </xsl:message>
  342.         </xsl:when>
  343.         <xsl:otherwise>
  344.           <xsl:apply-templates select="key('id',$rootid)"/>
  345.           <xsl:if test="$tex.math.in.alt != ''">
  346.             <xsl:apply-templates select="key('id',$rootid)" mode="collect.tex.math"/>
  347.           </xsl:if>
  348.         </xsl:otherwise>
  349.       </xsl:choose>
  350.     </xsl:when>
  351.     <xsl:otherwise>
  352.       <xsl:apply-templates select="/" mode="process.root"/>
  353.       <xsl:if test="$tex.math.in.alt != ''">
  354.         <xsl:apply-templates select="/" mode="collect.tex.math"/>
  355.       </xsl:if>
  356.     </xsl:otherwise>
  357.   </xsl:choose>
  358. </xsl:template>
  359.  
  360. <xsl:template match="*" mode="process.root">
  361.   <xsl:apply-templates select="."/>
  362. </xsl:template>
  363.  
  364. <xsl:template match="set|book|part|preface|chapter|appendix
  365.                      |article
  366.                      |reference|refentry
  367.                      |book/glossary|article/glossary
  368.                      |book/bibliography|article/bibliography
  369.                      |colophon">
  370.   <xsl:call-template name="process-chunk-element"/>
  371. </xsl:template>
  372.  
  373. <xsl:template match="sect1|sect2|sect3|sect4|sect5|section">
  374.   <xsl:variable name="ischunk">
  375.     <xsl:call-template name="chunk"/>
  376.   </xsl:variable>
  377.  
  378.   <xsl:choose>
  379.     <xsl:when test="not(parent::*)">
  380.       <xsl:call-template name="process-chunk-element"/>
  381.     </xsl:when>
  382.     <xsl:when test="$ischunk = 0">
  383.       <xsl:apply-imports/>
  384.     </xsl:when>
  385.     <xsl:otherwise>
  386.       <xsl:call-template name="process-chunk-element"/>
  387.     </xsl:otherwise>
  388.   </xsl:choose>
  389. </xsl:template>
  390.  
  391. <xsl:template match="setindex
  392.                      |book/index
  393.                      |article/index">
  394.   <!-- some implementations use completely empty index tags to indicate -->
  395.   <!-- where an automatically generated index should be inserted. so -->
  396.   <!-- if the index is completely empty, skip it. -->
  397.   <xsl:if test="count(*)>0 or $generate.index != '0'">
  398.     <xsl:call-template name="process-chunk-element"/>
  399.   </xsl:if>
  400. </xsl:template>
  401.  
  402. <!-- ==================================================================== -->
  403.  
  404. <xsl:template name="in.other.chunk">
  405.   <xsl:param name="chunk" select="."/>
  406.   <xsl:param name="node" select="."/>
  407.  
  408.   <xsl:variable name="is.chunk">
  409.     <xsl:call-template name="chunk">
  410.       <xsl:with-param name="node" select="$node"/>
  411.     </xsl:call-template>
  412.   </xsl:variable>
  413.  
  414. <!--
  415.   <xsl:message>
  416.     <xsl:text>in.other.chunk: </xsl:text>
  417.     <xsl:value-of select="name($chunk)"/>
  418.     <xsl:text> </xsl:text>
  419.     <xsl:value-of select="name($node)"/>
  420.     <xsl:text> </xsl:text>
  421.     <xsl:value-of select="$chunk = $node"/>
  422.     <xsl:text> </xsl:text>
  423.     <xsl:value-of select="$is.chunk"/>
  424.   </xsl:message>
  425. -->
  426.  
  427.   <xsl:choose>
  428.     <xsl:when test="$chunk = $node">0</xsl:when>
  429.     <xsl:when test="$is.chunk = 1">1</xsl:when>
  430.     <xsl:when test="count($node) = 0">0</xsl:when>
  431.     <xsl:otherwise>
  432.       <xsl:call-template name="in.other.chunk">
  433.         <xsl:with-param name="chunk" select="$chunk"/>
  434.         <xsl:with-param name="node" select="$node/parent::*"/>
  435.       </xsl:call-template>
  436.     </xsl:otherwise>
  437.   </xsl:choose>
  438. </xsl:template>
  439.  
  440. <xsl:template name="count.footnotes.in.this.chunk">
  441.   <xsl:param name="node" select="."/>
  442.   <xsl:param name="footnotes" select="$node//footnote"/>
  443.   <xsl:param name="count" select="0"/>
  444.  
  445. <!--
  446.   <xsl:message>
  447.     <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
  448.     <xsl:value-of select="name($node)"/>
  449.   </xsl:message>
  450. -->
  451.  
  452.   <xsl:variable name="in.other.chunk">
  453.     <xsl:call-template name="in.other.chunk">
  454.       <xsl:with-param name="chunk" select="$node"/>
  455.       <xsl:with-param name="node" select="$footnotes[1]"/>
  456.     </xsl:call-template>
  457.   </xsl:variable>
  458.  
  459.   <xsl:choose>
  460.     <xsl:when test="count($footnotes) = 0">
  461.       <xsl:value-of select="$count"/>
  462.     </xsl:when>
  463.     <xsl:otherwise>
  464.       <xsl:choose>
  465.         <xsl:when test="$in.other.chunk != 0">
  466.           <xsl:call-template name="count.footnotes.in.this.chunk">
  467.             <xsl:with-param name="node" select="$node"/>
  468.             <xsl:with-param name="footnotes"
  469.                             select="$footnotes[position() > 1]"/>
  470.             <xsl:with-param name="count" select="$count"/>
  471.           </xsl:call-template>
  472.         </xsl:when>
  473.         <xsl:when test="$footnotes[1]/ancestor::table
  474.                         |$footnotes[1]/ancestor::informaltable">
  475.           <xsl:call-template name="count.footnotes.in.this.chunk">
  476.             <xsl:with-param name="node" select="$node"/>
  477.             <xsl:with-param name="footnotes"
  478.                             select="$footnotes[position() > 1]"/>
  479.             <xsl:with-param name="count" select="$count"/>
  480.           </xsl:call-template>
  481.         </xsl:when>
  482.         <xsl:otherwise>
  483.           <xsl:call-template name="count.footnotes.in.this.chunk">
  484.             <xsl:with-param name="node" select="$node"/>
  485.             <xsl:with-param name="footnotes"
  486.                             select="$footnotes[position() > 1]"/>
  487.             <xsl:with-param name="count" select="$count + 1"/>
  488.           </xsl:call-template>
  489.         </xsl:otherwise>
  490.       </xsl:choose>
  491.     </xsl:otherwise>
  492.   </xsl:choose>
  493. </xsl:template>
  494.  
  495. <xsl:template name="process.footnotes.in.this.chunk">
  496.   <xsl:param name="node" select="."/>
  497.   <xsl:param name="footnotes" select="$node//footnote"/>
  498.  
  499. <!--
  500.   <xsl:message>process.footnotes.in.this.chunk</xsl:message>
  501. -->
  502.  
  503.   <xsl:variable name="in.other.chunk">
  504.     <xsl:call-template name="in.other.chunk">
  505.       <xsl:with-param name="chunk" select="$node"/>
  506.       <xsl:with-param name="node" select="$footnotes[1]"/>
  507.     </xsl:call-template>
  508.   </xsl:variable>
  509.  
  510.   <xsl:choose>
  511.     <xsl:when test="count($footnotes) = 0">
  512.       <!-- nop -->
  513.     </xsl:when>
  514.     <xsl:otherwise>
  515.       <xsl:choose>
  516.         <xsl:when test="$in.other.chunk != 0">
  517.           <xsl:call-template name="process.footnotes.in.this.chunk">
  518.             <xsl:with-param name="node" select="$node"/>
  519.             <xsl:with-param name="footnotes"
  520.                             select="$footnotes[position() > 1]"/>
  521.           </xsl:call-template>
  522.         </xsl:when>
  523.         <xsl:when test="$footnotes[1]/ancestor::table
  524.                         |$footnotes[1]/ancestor::informaltable">
  525.           <xsl:call-template name="process.footnotes.in.this.chunk">
  526.             <xsl:with-param name="node" select="$node"/>
  527.             <xsl:with-param name="footnotes"
  528.                             select="$footnotes[position() > 1]"/>
  529.           </xsl:call-template>
  530.         </xsl:when>
  531.         <xsl:otherwise>
  532.           <xsl:apply-templates select="$footnotes[1]"
  533.                                mode="process.footnote.mode"/>
  534.           <xsl:call-template name="process.footnotes.in.this.chunk">
  535.             <xsl:with-param name="node" select="$node"/>
  536.             <xsl:with-param name="footnotes"
  537.                             select="$footnotes[position() > 1]"/>
  538.           </xsl:call-template>
  539.         </xsl:otherwise>
  540.       </xsl:choose>
  541.     </xsl:otherwise>
  542.   </xsl:choose>
  543. </xsl:template>
  544.  
  545. <xsl:template name="process.footnotes">
  546.   <xsl:variable name="footnotes" select=".//footnote"/>
  547.   <xsl:variable name="fcount">
  548.     <xsl:call-template name="count.footnotes.in.this.chunk">
  549.       <xsl:with-param name="node" select="."/>
  550.       <xsl:with-param name="footnotes" select="$footnotes"/>
  551.     </xsl:call-template>
  552.   </xsl:variable>
  553.  
  554. <!--
  555.   <xsl:message>
  556.     <xsl:value-of select="name(.)"/>
  557.     <xsl:text> fcount: </xsl:text>
  558.     <xsl:value-of select="$fcount"/>
  559.   </xsl:message>
  560. -->
  561.  
  562.   <!-- Only bother to do this if there's at least one non-table footnote -->
  563.   <xsl:if test="$fcount > 0">
  564.     <div class="footnotes">
  565.       <br/>
  566.       <hr width="100" align="left"/>
  567.       <xsl:call-template name="process.footnotes.in.this.chunk">
  568.         <xsl:with-param name="node" select="."/>
  569.         <xsl:with-param name="footnotes" select="$footnotes"/>
  570.       </xsl:call-template>
  571.     </div>
  572.   </xsl:if>
  573. </xsl:template>
  574.  
  575. <xsl:template name="process.chunk.footnotes">
  576.   <xsl:variable name="is.chunk">
  577.     <xsl:call-template name="chunk"/>
  578.   </xsl:variable>
  579.   <xsl:if test="$is.chunk = 1">
  580.     <xsl:call-template name="process.footnotes"/>
  581.   </xsl:if>
  582. </xsl:template>
  583.  
  584. </xsl:stylesheet>
  585. This resource fork intentionally left blank   ˇˇ